<template>
	<view class="page">
		<image src="@/static/image/login_bg.png" class="bg-img"></image>
		<view class="info-block">
			<image src="/static/image/name.png" mode="widthFix" class="title"></image>
			<view class="phone">182****2023</view>
			<view class="btn-item" @click="getLogin">一键登录</view>
			<view class="type" @click="navigate('/pages/login/login')">切换账号</view>
			<radio-group @change="changeGroup" class="radio-item">
				<radio style="transform:scale(0.7)" color="#3175ff" :checked="form.checked"></radio>
				<view class="text">我已阅读并同意</view>
				<view class="text color" @click="navigate('')">《用户服务协议》</view>
				<view class="text">和</view>
				<view class="text color" @click="navigate('')">《隐私政策》</view>
			</radio-group>
		</view>
	</view>
</template>

<script>
	import {
		validate
	} from '@/util/validate.js';
	export default {
		data() {
			return {
				form: {
					checked: false
				},
				rule: {
					checked: {
						name: '',
						required: false,
						validator: function(value, form, callback) {
							if (value == false) {
								callback('请阅读并同意《用户服务协议》和《隐私政策》！');
							}
							callback();
						}
					},
				},
			}
		},
		methods: {
			changeGroup(e) {
				this.form.checked = true
			},
			getLogin() {
				if (validate(this.form, this.rule)) {
					// getLoginApi(this.form).then((res) => {
					// 	setStorage('token', res.token, 604800)
					// 	this.showToast('登录成功！', () => {
					// 		uni.navigateBack();
					// 	}, 1000)
					uni.switchTab({
						url: '/pages/index/index'
					})
					// })
					// .finally(() => {
					// 	this.getCaptcha()
					// })
				}
			}
		},
		onLoad(e) {},

	}
</script>

<style lang="scss" scoped>
	.page {
		overflow: hidden;
		min-height: 100vh;
		background-color: #F7F6F9;

		.bg-img {
			width: 100%;
			min-height: 100vh;
			position: absolute;
		}

		.info-block {
			position: relative;
			height: 100vh;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: center;

			.title {
				margin-top: 200rpx;
				width: 38%;
			}

			.phone {
				margin-top: 140rpx;
				font-weight: bold;
				font-size: 60rpx;
			}

			.type {
				margin-top: -70rpx;
				font-size: 30rpx;
			}

			.radio-item {
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				margin: 40rpx 0;

				.text {
					font-size: 28rpx;
					color: #767676;
				}

				.color {
					color: #3175ff;
					font-weight: bold;
				}
			}
		}

		.btn-item {
			width: calc(100% - 100rpx);
			height: 90rpx;
			margin-top: 30rpx;
			border-radius: 60rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background: #3175ff;
			color: #ffffff;
			margin-top: 40rpx;
		}
	}
</style>